package com.example.listener.page

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.example.listener.R
import com.example.listener.databinding.FragmentMainBinding

/**
 *
 * @author: xct
 * create on: 2022/8/30 10:52
 *
 */
class MainFragment : Fragment() {


    private lateinit var viewBinding: FragmentMainBinding

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        // Inflate the layout for this fragment
        return FragmentMainBinding.inflate(inflater, container, false)
            .also { viewBinding = it }
            .root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        viewBinding.apply {
            btnBrightness.setOnClickListener {
                findNavController().navigate(R.id.brightnessFragment)
            }

            btnVolume.setOnClickListener {
                findNavController().navigate(R.id.volumeFragment)
            }

            btnWifi.setOnClickListener {
                findNavController().navigate(R.id.wifiFragment)
            }

            btnBluetooth.setOnClickListener {
                findNavController().navigate(R.id.bluetoothListFragment)
            }
        }
    }

}